package com.example.JavaDemo.Controller;




/**
 * 接口文档访问地址 http://127.0.0.1:8089/swagger-ui/index.html
 * apifox 导入接口数据 http://127.0.0.1:8089/v2/api-docs
 */
import com.example.JavaDemo.domain.Community;
import com.example.JavaDemo.domain.Notice;
import com.example.JavaDemo.service.INoticeService;

import com.example.comon.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


import java.util.List;
@RestController
@RequestMapping("/notice")
@Api(value="notice",tags="公告管理")
public class NoticeController {
    @Autowired
    private INoticeService noticeService;


    @GetMapping("/getNoticeList")
    @ApiOperation("查询公告")
    public R<List<Notice>> getNoticeList(Notice notice){
        List<Notice> list = noticeService.selectNotice(notice);
        return R.success(list);    }

    @PostMapping("/addNotice")
    @ApiOperation("增加公告")
    public R<Notice> addNotice(@RequestBody Notice notice){
        noticeService.insertNotice(notice);
        return R.success(notice);
    }

    @PostMapping("/updateNoticeById")
    @ApiOperation("修改公告")
    public R<List<Community>> updateNoticeById(@RequestBody Notice notice){
        noticeService.updateNoticeById(notice);
        return R.success();
    }

    @DeleteMapping("/delNoticeById")
    @ApiOperation("删除公告")
    public R<List<Community>> delNoticeById(String id){
        noticeService.delNoticeById(id);
        return R.success();
    }

}
